# -*- coding:utf-8 -*-

import ConfigParser,time,datetime


def INIwrite(aCard,aCode):
    config = ConfigParser.ConfigParser()
    config.add_section(aCard)
    config.set(aCard, "card",aCard)
    config.set(aCard, "code",aCode)
    timenow = int(time.time())
    config.set(aCard, "time",timenow)
    config.write(open("card_code.ini", "r+"))


def INIread(aCard): 
    try:
        config = ConfigParser.ConfigParser()
        config.read('card_code.ini')
        return config.get(aCard,"code") + "./." + config.get(aCard,"time")
    except:
        return -1

if __name__ == '__main__':
    #print ""
    print INIwrite("12345",12325)
    print INIread("12345")


